/**
 * 
 */
package com.common.bean;

import org.json.JSONException;
import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.common.StarAppConst.IM_MESSAGE_KEY;
import com.common.allCommon.JSONObjecthelper;

/**
 * 用户成长事件消息类,用户保存用户升级IM消息数据存储类<br>
 * Created 2014-11-3 下午3:15:36
 * @version
 * @author ChuXY
 * 
 * @see
 */
public class UserDevelopEventData extends AppMsgData implements ICommonImDataStruct ,Parcelable {

    /** 消息类型 */
    private String mType = "";
    /**
     * 消息内容
     */
    private String mMessage = "";

    /** 时间戳 */
    private long mTime = 0;

    /** 昵称 */
    private String mUniqueName = "";

    /** 用户id */
    private long mUid = 0;

    private long mFileId=0;
    
	public long getFileId() {
		return mFileId;
	}

	
	public void setmFileId(long fileId) {
		this.mFileId = fileId;
	}

	/**
     * Creates a new instance of UserDevelopEventData. <br>
     * Created 2014-11-3 下午5:30:39
     */
    public UserDevelopEventData() {
        super();
    }

    public String getType() {
        return mType;
    }

    public void setType(String mType) {
        this.mType = mType;
    }

    public String getMessage() {
        return mMessage;
    }

    
    public void setMessage(String mMessage) {
        this.mMessage = mMessage;
    }

    /**
     * 获取时间戳
     * 
     * <br>
     * Created 2014-11-4 下午1:47:08
     * 
     * @return 时间戳
     * @author ChuXY
     */
    public long getTime() {
        return mTime;
    }

    /**
     * 设置时间戳
     * 
     * <br>
     * Created 2014-11-4 下午1:47:19
     * 
     * @param mTime
     *            时间戳
     * @author ChuXY
     */
    public void setTime(long mTime) {
        this.mTime = mTime;
    }

    /**
     * 获取昵称
     * 
     * <br>
     * Created 2014-11-4 下午1:47:30
     * 
     * @return 昵称
     * @author ChuXY
     */
    public String getUniqueName() {
        return mUniqueName;
    }

    /**
     * 设置昵称
     * 
     * <br>
     * Created 2014-11-4 下午1:47:39
     * 
     * @param mUniqueName
     *            昵称
     * @author ChuXY
     */
    public void setUniqueName(String mUniqueName) {
        this.mUniqueName = mUniqueName;
    }

    /**
     * 获取uid
     * 
     * <br>
     * Created 2014-11-4 下午1:47:49
     * 
     * @return 用户id
     * @author ChuXY
     */
    public long getUid() {
        return mUid;
    }

    /**
     * 设置uid
     * 
     * <br>
     * Created 2014-11-4 下午1:48:05
     * 
     * @param mUid
     * @author ChuXY
     */
    public void setUid(long mUid) {
        this.mUid = mUid;
    }

    public static final Parcelable.Creator<UserDevelopEventData> CREATOR = new Creator<UserDevelopEventData>() {

        @Override
        public UserDevelopEventData[] newArray(int size) {
            return new UserDevelopEventData[size];
        }

        @Override
        public UserDevelopEventData createFromParcel(Parcel in) {
            return new UserDevelopEventData(in);
        }
    };

    /**
     * Creates a new instance of UserUpdateData. <br>
     * Created 2014-11-3 下午3:17:45
     * 
     * @param in
     */
    public UserDevelopEventData(Parcel in) {
        mMessage = in.readString();
        mTime = in.readLong();
        mType = in.readString();
        mUniqueName = in.readString();
        mUid = in.readLong();
        mFileId=in.readLong();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(mMessage);
        dest.writeLong(mTime);
        dest.writeString(mType);
        dest.writeString(mUniqueName);
        dest.writeLong(mUid);
        dest.writeLong(mFileId);
    }

    @Override
    public void parseJson(String strJson) {
        if (TextUtils.isEmpty(strJson)) {
            return;
        }

        JSONObject jsonData = null;
        try {
            jsonData = new JSONObject(strJson);
        } catch (JSONException e) {
            return;
        }
        mType = JSONObjecthelper.getString(jsonData, IM_MESSAGE_KEY.TAG_TYPE);
        mMessage = JSONObjecthelper.getString(jsonData, IM_MESSAGE_KEY.TAG_MSG);
        mTime = JSONObjecthelper.getLong(jsonData, IM_MESSAGE_KEY.TAG_TIME);
        mUid = JSONObjecthelper.getLong(jsonData, IM_MESSAGE_KEY.TAG_USERID);
        mUniqueName = JSONObjecthelper.getString(jsonData, IM_MESSAGE_KEY.TAG_UNIQUENAME);
        mFileId = JSONObjecthelper.getLong(jsonData, IM_MESSAGE_KEY.TAG_CHECK_CODE);
    }

	@Override
	public String transDataToJSON() {
		JSONObject json=new JSONObject();
		try {
			json.put(IM_MESSAGE_KEY.TAG_TYPE, mType);
			json.put(IM_MESSAGE_KEY.TAG_MSG, mMessage);
			json.put(IM_MESSAGE_KEY.TAG_TIME, mTime);
			json.put(IM_MESSAGE_KEY.TAG_UNIQUENAME, mUniqueName);
			json.put(IM_MESSAGE_KEY.TAG_USERID, mUid);
			json.put(IM_MESSAGE_KEY.TAG_CHECK_CODE, mFileId);
		} catch (JSONException e) {
			e.printStackTrace();
			return null;
		}
		return json.toString();
	}

	@Override
	public void setDataFromJSON(String jsonString) {
		parseJson(jsonString);
	}

	@Override
	public void setFileId(long fileId) {
		mFileId=fileId;
	}


	@Override
	public long getLongExtraData() {
		return 0;
	}


	/**
	 * 
	 * <br>Created 2014-11-30 下午4:09:00
	 * @return
	 * @author       ChuXY	
	*/
	
	@Override
	public String getStringExtraData() {
		// TODO Auto-generated method stub
		return null;
	}
}
